import Person from "@/components/Person";
import Search from "@/components/Search";
import Sheet from "@/components/Sheet";
import { Breadcrumb, Card, Space } from "antd";
import dayjs from "dayjs";
import { useState } from "react";
const columns = [
  {
    title: '日志内容',
    dataIndex: 'content',
  },
  {
    title: '日志类型',
    dataIndex: 'type'
  },
  {
    title: '操作人',
    dataIndex: 'creator',
    render: (text, record, index) => {
      return <Person text={text} index={index} />
    }
  },
  {
    title: '操作时间',
    dataIndex: 'time',
    sorter: (a, b) => a.time - b.time,
  }
]
const dataSource = {
  total: 20,
  data: Array.from({
    length: 46,
  }).map((_, i) => ({
    key: i,
    content: '用户登录系统',
    type: `登录${i}`,
    creator: '章三',
    time: dayjs(new Date()).format('YYYY-MM-DD HH:mm:ss'),
  }))
};
export default function Log() {
  const [page, setPage] = useState({ pageNum: 1, pageSize: 10 })
  const handleSearch = (val) => {
    console.log(val)
  }
  // 分页
  const handlePage = (pageNum, pageSize) => {
    setPage({
      pageNum,
      pageSize
    })
  }
  return (
    <div>
      <h2 className="headline">系统日志</h2>
      <Space direction="vertical" size={16} style={{ width: "100%" }}>
        <Search onSearch={handleSearch}></Search>
        <Card>
          <Sheet columns={columns} dataSource={dataSource} page={page} onChange={handlePage}></Sheet>
        </Card>
      </Space>
    </div>
  )
}